package org.nerve.webmagic.pool;

import org.nerve.webmagic.bean.Data;

import java.util.Map;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * org.nerve.webmagic.pool
 * Created by zengxm on 2016/4/21 0021.
 */
public final class DataPool {
	private static BlockingDeque<Data> innerDeque=new LinkedBlockingDeque<>();
	private static AtomicInteger atomicCount=new AtomicInteger(0);

	public static void push(Data data){
		innerDeque.push(data);
		atomicCount.incrementAndGet();

		System.out.println("data count="+atomicCount.longValue());
	}

	public static Data take() throws InterruptedException {
		return innerDeque.take();
	}
}
